package cn.tedu._05mvcboot03.controller;

import cn.tedu._05mvcboot03.common.response.JsonResult;
import cn.tedu._05mvcboot03.mapper.ArticleMapper;
import cn.tedu._05mvcboot03.pojo.vo.ArticleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "02.文章模块")
@Slf4j
@Validated
@RestController
@RequestMapping("/v1/users/")
public class ArticleController {
    @Autowired
    private ArticleMapper articleMapper;
    @ApiImplicitParam(name="id",value = "指定文章ID",required = true,dataType = "int")
    @ApiOperation("指定查询文章功能")
    @GetMapping("selectByArticleId")
    public JsonResult selectByArticleId(@Range(min=1,max = 100,message = "文章id必须在1-100之间") @RequestParam Long id){
        log.debug("id="+id);
        return JsonResult.ok(articleMapper.selectById(id));
    }
}
